/*
 * Copyright.
 **/
package com.atguigu.gulimall.product.exception;

import com.atguigu.gulimall.product.exception.enums.ExceptionErrorCodeEnum;
import com.atguigu.gulimall.product.utils.SpringContextUtil;
import lombok.Getter;
import org.springframework.context.MessageSource;

/**
 * @author lax
 */
@Getter
public class GuliProductRuntimeException extends RuntimeException {
    private static MessageSource messageSource = SpringContextUtil.getBean(MessageSource.class);

    private final String errorCode;

    private final String errorKey;

    public GuliProductRuntimeException(final String errorCode, final String errorKey) {
        this.errorCode = errorCode;
        this.errorKey = errorKey;
    }

    public GuliProductRuntimeException(final ExceptionErrorCodeEnum errorCodeEnum) {
        this.errorCode = errorCodeEnum.getErrorCode();
        this.errorKey = errorCodeEnum.getErrorKey();
    }
}
